package test.tcp.chat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ChatClient {
	public static void main(String args[]) {
		try {
			// 启动客户端线程
			ClientThread client = new ClientThread(args[0]);
			client.start();

			// 键盘输入流
			BufferedReader sin = new BufferedReader(new InputStreamReader(
					System.in));

			// 循环读取键盘输入
			String readline;
			while ((readline = sin.readLine()) != null) {
				if (readline.equals("bye")) {
					// 退出系统
					client.close();
					System.exit(0);
				}
				// 发送消息
				client.send(readline);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
